<?php
// $Id: matchdart.views.inc 182 2010-03-13 17:49:35Z mwi.nor $

/**
 * Implementation of hook_views_data().
 */
function matchdart_views_data() {

  //------------------------------------------------------
  // MatchDart! Events Views Table
  //------------------------------------------------------
  
  $data['matchdart_events']['table']['group']  = t('MatchDart! Event');

  $data['matchdart_events']['table']['base'] = array(
                                                      'field' => 'nid', // Governs the whole mozilla
                                                      'title' => t('MatchDart! Events'),
                                                      'help' => t("View displays MatchDart! Events."),
                                                      );

  //MatchDart! Events - TABLE JOINS

  $data['matchdart_events']['table']['join'] = array(
                                                    // Direct link to node table.
                                                    'node' => array(
                                                                    'left_field' => 'nid',
                                                                    'field' => 'nid',
                                                                    ),
                                                     // Direct link to node table (series).
                                                    'node' => array(
                                                                    'left_field' => 'series_id',
                                                                    'field' => 'nid',
                                                                    ),
                                                    );
                                                    // TODO : link to player / team table
                                                     
  //MatchDart! Events - FIELDS

  //NID (from node.nid)
  $data['matchdart_events']['nid'] = array(
                                         'title' => t('ID'),
                                         'help' => t('Relates the Node to the Event'),
                                         'field' => array(
                                                          'handler' => 'views_handler_field_numeric',
                                                          'click sortable' => TRUE,
                                                          ),

                                         'argument' => array(
                                                             'handler' => 'views_handler_argument_numeric',
                                                             'numeric' => TRUE,
                                                             ),

                                         'filter' => array(
                                                           'handler' => 'views_handler_filter_numeric',
                                                           ),

                                         'sort' => array(
                                                         'handler' => 'views_handler_sort',
                                                         ),
                                         'relationship' => array(
                                                                 'base' => 'node',
                                                                 'field' => 'nid',
                                                                 'handler' => 'views_handler_relationship',
                                                                 'label' => t('MatchDart! Event'),
                                                                 ),
                                         );

  //SERIES ID (from node.nid)
  $data['matchdart_events']['series_id'] = array(
                                                'title' => t('Series'),
                                                'help' => t('Relates a Series to the Event.'),
                                                'field' => array(
                                                                 'handler' => 'views_handler_field_numeric',
                                                                 'click sortable' => TRUE,
                                                                 ),
                                                'sort' => array(
                                                                'handler' => 'views_handler_sort',
                                                                ),
                                                'relationship' => array(
                                                                        'base' => 'node',
                                                                        'field' => 'nid',
                                                                        'handler' => 'views_handler_relationship',
                                                                        'label' => t('MatchDart! Event: Series'),
                                                                        ),
                                                );

  //PLAYERS (csv list of player ids from matchdart_players.nid)
  $data['matchdart_events']['players'] = array(
                                             'title' => t('Players'),
                                             'help' => t('The Players competing in this Event'),
                                             'field' => array(
                                                              'handler' => 'views_handler_field',
                                                              'click sortable' => TRUE,
                                                              ),

                                             'argument' => array(
                                                                 'handler' => 'views_handler_argument',
                                                                 ),

                                             'filter' => array(
                                                               'handler' => 'views_handler_filter_string',
                                                               'allow empty' => TRUE,
                                                               ),

                                             'sort' => array(
                                                             'handler' => 'views_handler_sort',
                                                             ),
                                             );

  //TEAMS (csv list of team ids from matchdart_teams.nid)
  $data['matchdart_events']['teams'] = array(
                                             'title' => t('Teams'),
                                             'help' => t('The Teams competing in this Event'),
                                             'field' => array(
                                                              'handler' => 'views_handler_field',
                                                              'click sortable' => TRUE,
                                                              ),

                                             'argument' => array(
                                                                 'handler' => 'views_handler_argument',
                                                                 ),

                                             'filter' => array(
                                                               'handler' => 'views_handler_filter_string',
                                                               'allow empty' => TRUE,
                                                               ),

                                             'sort' => array(
                                                             'handler' => 'views_handler_sort',
                                                             ),
                                             );
                                             
  //numeric POINTS WIN
  $data['matchdart_events']['points_win'] = array(
                                         'title' => t('Points Win'),
                                         'help' => t('The number of points for a win'),
                                         'field' => array(
                                                          'handler' => 'views_handler_field_numeric',
                                                          'click sortable' => TRUE,
                                                          ),

                                         'argument' => array(
                                                             'handler' => 'views_handler_argument_numeric',
                                                             'numeric' => TRUE,
                                                             ),

                                         'filter' => array(
                                                           'handler' => 'views_handler_filter_numeric',
                                                           ),

                                         'sort' => array(
                                                         'handler' => 'views_handler_sort',
                                                         ),
                                         );

  //numeric POINTS DRAW
  $data['matchdart_events']['points_draw'] = array(
                                         'title' => t('Points Draw'),
                                         'help' => t('The number of points for a draw'),
                                         'field' => array(
                                                          'handler' => 'views_handler_field_numeric',
                                                          'click sortable' => TRUE,
                                                          ),

                                         'argument' => array(
                                                             'handler' => 'views_handler_argument_numeric',
                                                             'numeric' => TRUE,
                                                             ),

                                         'filter' => array(
                                                           'handler' => 'views_handler_filter_numeric',
                                                           ),

                                         'sort' => array(
                                                         'handler' => 'views_handler_sort',
                                                         ),
                                         );

  //numeric POINTS LOSE
  $data['matchdart_events']['points_lose'] = array(
                                         'title' => t('Points Lose'),
                                         'help' => t('The number of points for a lose'),
                                         'field' => array(
                                                          'handler' => 'views_handler_field_numeric',
                                                          'click sortable' => TRUE,
                                                          ),

                                         'argument' => array(
                                                             'handler' => 'views_handler_argument_numeric',
                                                             'numeric' => TRUE,
                                                             ),

                                         'filter' => array(
                                                           'handler' => 'views_handler_filter_numeric',
                                                           ),

                                         'sort' => array(
                                                         'handler' => 'views_handler_sort',
                                                         ),
                                         );

  //LINE (csv list of table positions)
  $data['matchdart_events']['line'] = array(
                                             'title' => t('Line'),
                                             'help' => t('Table positions after which a line is drawn.'),
                                             'field' => array(
                                                              'handler' => 'views_handler_field',
                                                              'click sortable' => TRUE,
                                                              ),

                                             'argument' => array(
                                                                 'handler' => 'views_handler_argument',
                                                                 ),

                                             'filter' => array(
                                                               'handler' => 'views_handler_filter_string',
                                                               'allow empty' => TRUE,
                                                               ),

                                             'sort' => array(
                                                             'handler' => 'views_handler_sort',
                                                             ),
                                             );
                                             
  //url LOGO
  $data['matchdart_events']['logo'] = array(
                                             'title' => t('Logo'),
                                             'help' => t('URL to Event Logo file.'),
                                             'field' => array(
                                                              'handler' => 'views_handler_field_url',
                                                              'click sortable' => TRUE,
                                                              ),

                                             'argument' => array(
                                                                 'handler' => 'views_handler_argument',
                                                                 ),

                                             'filter' => array(
                                                               'handler' => 'views_handler_filter_string',
                                                               'allow empty' => TRUE,
                                                               ),

                                             'sort' => array(
                                                             'handler' => 'views_handler_sort',
                                                             ),
                                             );
                                             
  //GAME TYPE type of the game played in the event
  $data['matchdart_events']['game_type'] = array(
                                             'title' => t('Game Type'),
                                             'help' => t('Type of the Games played in this Event.'),
                                             'field' => array(
                                                              'handler' => 'views_handler_field',
                                                              'click sortable' => TRUE,
                                                              ),

                                             'argument' => array(
                                                                 'handler' => 'views_handler_argument',
                                                                 ),

                                             'filter' => array(
                                                               'handler' => 'views_handler_filter_string',
                                                               'allow empty' => TRUE,
                                                               ),

                                             'sort' => array(
                                                             'handler' => 'views_handler_sort',
                                                             ),
                                             );
                                             
  //LEGEND
  $data['matchdart_events']['legend'] = array(
                                             'title' => t('Legend'),
                                             'help' => t('Display Legend under Event table.'),
                                             'field' => array(
                                                              'handler' => 'views_handler_field',
                                                              'click sortable' => TRUE,
                                                              ),

                                             'argument' => array(
                                                                 'handler' => 'views_handler_argument',
                                                                 ),

                                             'filter' => array(
                                                               'handler' => 'views_handler_filter_string',
                                                               'allow empty' => TRUE,
                                                               ),

                                             'sort' => array(
                                                             'handler' => 'views_handler_sort',
                                                             ),
                                             );
                                             
  //boolean USE DRAWS
  $data['matchdart_events']['use_draws'] = array(
                                                 'title' => t('Use Draws'),
                                                 'help' => t('Is a Draw possible in this Event?'),
                                                 'field' => array(
                                                                  'handler' => 'views_handler_field_boolean',
                                                                  'click sortable' => TRUE,
                                                                  ),

                                                 'argument' => array(
                                                                     'handler' => 'views_handler_argument',
                                                                     ),

                                                 'filter' => array(
                                                                   'handler' => 'views_handler_filter_boolean_operator',
                                                                   ),

                                                 'sort' => array(
                                                                 'handler' => 'views_handler_sort',
                                                                 ),
                                                 );

  //boolean USE PLAYOFFS
  $data['matchdart_events']['use_playoffs'] = array(
                                                 'title' => t('Use Playoffs'),
                                                 'help' => t('Use Playoff matches in this Event?'),
                                                 'field' => array(
                                                                  'handler' => 'views_handler_field_boolean',
                                                                  'click sortable' => TRUE,
                                                                  ),

                                                 'argument' => array(
                                                                     'handler' => 'views_handler_argument',
                                                                     ),

                                                 'filter' => array(
                                                                   'handler' => 'views_handler_filter_boolean_operator',
                                                                   ),

                                                 'sort' => array(
                                                                 'handler' => 'views_handler_sort',
                                                                 ),
                                                 );

  //boolean USE SETS
  $data['matchdart_events']['use_sets'] = array(
                                                 'title' => t('Use Sets'),
                                                 'help' => t('Use sets in this Event?'),
                                                 'field' => array(
                                                                  'handler' => 'views_handler_field_boolean',
                                                                  'click sortable' => TRUE,
                                                                  ),

                                                 'argument' => array(
                                                                     'handler' => 'views_handler_argument',
                                                                     ),

                                                 'filter' => array(
                                                                   'handler' => 'views_handler_filter_boolean_operator',
                                                                   ),

                                                 'sort' => array(
                                                                 'handler' => 'views_handler_sort',
                                                                 ),
                                                 );

  //boolean USE TEAMS
  $data['matchdart_events']['use_teams'] = array(
                                                 'title' => t('Use Teams'),
                                                 'help' => t('Is this a Team Event (y) or Players only (n)?'),
                                                 'field' => array(
                                                                  'handler' => 'views_handler_field_boolean',
                                                                  'click sortable' => TRUE,
                                                                  ),

                                                 'argument' => array(
                                                                     'handler' => 'views_handler_argument',
                                                                     ),

                                                 'filter' => array(
                                                                   'handler' => 'views_handler_filter_boolean_operator',
                                                                   ),

                                                 'sort' => array(
                                                                 'handler' => 'views_handler_sort',
                                                                 ),
                                                 );

  //boolean USE VENUES
  $data['matchdart_events']['use_venues'] = array(
                                                 'title' => t('Use Venues'),
                                                 'help' => t('Use venues in this Event?'),
                                                 'field' => array(
                                                                  'handler' => 'views_handler_field_boolean',
                                                                  'click sortable' => TRUE,
                                                                  ),

                                                 'argument' => array(
                                                                     'handler' => 'views_handler_argument',
                                                                     ),

                                                 'filter' => array(
                                                                   'handler' => 'views_handler_filter_boolean_operator',
                                                                   ),

                                                 'sort' => array(
                                                                 'handler' => 'views_handler_sort',
                                                                 ),
                                                 );

  //boolean USE XSTATS
  $data['matchdart_events']['use_xstats'] = array(
                                                 'title' => t('Use xStats'),
                                                 'help' => t('Use extended Statistics in this Event?'),
                                                 'field' => array(
                                                                  'handler' => 'views_handler_field_boolean',
                                                                  'click sortable' => TRUE,
                                                                  ),

                                                 'argument' => array(
                                                                     'handler' => 'views_handler_argument',
                                                                     ),

                                                 'filter' => array(
                                                                   'handler' => 'views_handler_filter_boolean_operator',
                                                                   ),

                                                 'sort' => array(
                                                                 'handler' => 'views_handler_sort',
                                                                 ),
                                                 );

  
  //------------------------------------------------------
  // MatchDart! Players Views Table
  //------------------------------------------------------
  
  $data['matchdart_players']['table']['group']  = t('MatchDart! Player');

  $data['matchdart_players']['table']['base'] = array(
                                                      'field' => 'nid', // Governs the whole mozilla
                                                      'title' => t('MatchDart! Players'),
                                                      'help' => t("View displays MatchDart! Players."),
                                                      );

  //MatchDart! Players - TABLE JOINS

  $data['matchdart_players']['table']['join'] = array(
                                                    // Link to node table.
                                                    'node' => array(
                                                                    'left_field' => 'nid',
                                                                    'field' => 'nid',
                                                                    ),
                                                    // Link to user table.
                                                    'user' => array(
                                                                    'left_field' => 'uid',
                                                                    'field' => 'user_id',
                                                                    ),
                                                    // TODO : Link to teams table.
//                                                    'matchdart_teams' => array(
//                                                                    'left_field' => 'teams',
//                                                                    'field' => 'nid',
//                                                                    ),
                                                    // Link to matchdart_venues table.
                                                    'matchdart_venues' => array(
                                                                    'left_field' => 'venue_id',
                                                                    'field' => 'nid',
                                                                    ),
                                                    );

  //MatchDart! Players - FIELDS

  //NID (from node.nid)
  $data['matchdart_players']['nid'] = array(
                                         'title' => t('ID'),
                                         'help' => t('Relates the Node to the Player'),
                                         'field' => array(
                                                          'handler' => 'views_handler_field_numeric',
                                                          'click sortable' => TRUE,
                                                          ),

                                         'argument' => array(
                                                             'handler' => 'views_handler_argument_numeric',
                                                             'numeric' => TRUE,
                                                             ),

                                         'filter' => array(
                                                           'handler' => 'views_handler_filter_numeric',
                                                           ),

                                         'sort' => array(
                                                         'handler' => 'views_handler_sort',
                                                         ),
                                         'relationship' => array(
                                                                 'base' => 'node',
                                                                 'field' => 'nid',
                                                                 'handler' => 'views_handler_relationship',
                                                                 'label' => t('MatchDart! Player'),
                                                                 ),
                                         );

  //USER ID (from user.uid)
  $data['matchdart_players']['user_id'] = array(
                                                'title' => t('User'),
                                                'help' => t('Relates a Drupal User to the Player.'),
                                                'field' => array(
                                                                 'handler' => 'views_handler_field_numeric',
                                                                 'click sortable' => TRUE,
                                                                 ),
                                                'sort' => array(
                                                                'handler' => 'views_handler_sort',
                                                                ),
                                                'relationship' => array(
                                                                        'base' => 'users',
                                                                        'field' => 'uid',
                                                                        'handler' => 'views_handler_relationship',
                                                                        'label' => t('MatchDart! Player: User'),
                                                                        ),
                                                );

  //TEAMS (csv list of team ids from matchdart_teams.nid)
  $data['matchdart_players']['teams'] = array(
                                             'title' => t('Teams'),
                                             'help' => t('The Teams of this Player'),
                                             'field' => array(
                                                              'handler' => 'views_handler_field',
                                                              'click sortable' => TRUE,
                                                              ),

                                             'argument' => array(
                                                                 'handler' => 'views_handler_argument',
                                                                 ),

                                             'filter' => array(
                                                               'handler' => 'views_handler_filter_string',
                                                               'allow empty' => TRUE,
                                                               ),

                                             'sort' => array(
                                                             'handler' => 'views_handler_sort',
                                                             ),
                                             );
                                             
  //VENUE ID (from matchdart_venues.nid)
  $data['matchdart_players']['venue_id'] = array(
                                                'title' => t('Venue'),
                                                'help' => t('Relates a Venue to the Player.'),
                                                'field' => array(
                                                                 'handler' => 'views_handler_field_numeric',
                                                                 'click sortable' => TRUE,
                                                                 ),
                                                'sort' => array(
                                                                'handler' => 'views_handler_sort',
                                                                ),
                                                'relationship' => array(
                                                                        'base' => 'node',
                                                                        'field' => 'nid',
                                                                        'handler' => 'views_handler_relationship',
                                                                        'label' => t('MatchDart! Player: Venue'),
                                                                        ),
                                                );

                                                    
  //------------------------------------------------------
  // MatchDart! Series Views Table
  //------------------------------------------------------
  
//  $data['matchdart_series']['table']['group']  = t('MatchDart! Series');
//
//  $data['matchdart_series']['table']['base'] = array(
//                                                      'field' => 'series_id', // Governs the whole mozilla
//                                                      'title' => t('MatchDart! Series'),
//                                                      'help' => t("View displays MatchDart! Series."),
//                                                      );

  
  //------------------------------------------------------
  // MatchDart! Venues Views Table
  //------------------------------------------------------
  
  $data['matchdart_venues']['table']['group']  = t('MatchDart! Venue');

  $data['matchdart_venues']['table']['base'] = array(
                                                      'field' => 'nid', // Governs the whole mozilla
                                                      'title' => t('MatchDart! Venues'),
                                                      'help' => t("View displays MatchDart! Venues."),
                                                      );

  //MatchDart! Venues - TABLE JOINS

  $data['matchdart_venues']['table']['join'] = array(
                                                    // Link to node table.
                                                    'node' => array(
                                                                    'left_field' => 'nid',
                                                                    'field' => 'nid',
                                                                    ),
                                                    // Link to matchdart_venue table (substitute).
                                                    'matchdart_venue' => array(
                                                                    'left_field' => 'nid',
                                                                    'field' => 'substitute',
                                                                    ),
                                                    );

  //MatchDart! Venues - FIELDS

  //NID (from node.nid)
  $data['matchdart_venues']['nid'] = array(
                                         'title' => t('ID'),
                                         'help' => t('Relates the Node to the Venue'),
                                         'field' => array(
                                                          'handler' => 'views_handler_field_numeric',
                                                          'click sortable' => TRUE,
                                                          ),

                                         'argument' => array(
                                                             'handler' => 'views_handler_argument_numeric',
                                                             'numeric' => TRUE,
                                                             ),

                                         'filter' => array(
                                                           'handler' => 'views_handler_filter_numeric',
                                                           ),

                                         'sort' => array(
                                                         'handler' => 'views_handler_sort',
                                                         ),
                                         'relationship' => array(
                                                                 'base' => 'node',
                                                                 'field' => 'nid',
                                                                 'handler' => 'views_handler_relationship',
                                                                 'label' => t('MatchDart! Venue'),
                                                                 ),
                                         );

  //LOCATION
  $data['matchdart_venues']['location'] = array(
                                             'title' => t('Location'),
                                             'help' => t('Help Location.'),
                                             'field' => array(
                                                              'handler' => 'views_handler_field',
                                                              'click sortable' => TRUE,
                                                              ),

                                             'argument' => array(
                                                                 'handler' => 'views_handler_argument',
                                                                 ),

                                             'filter' => array(
                                                               'handler' => 'views_handler_filter_string',
                                                               'allow empty' => TRUE,
                                                               ),

                                             'sort' => array(
                                                             'handler' => 'views_handler_sort',
                                                             ),
                                             );
                                             
  //ADDRESS
  $data['matchdart_venues']['address'] = array(
                                             'title' => t('Address'),
                                             'help' => t('Help Address.'),
                                             'field' => array(
                                                              'handler' => 'views_handler_field',
                                                              'click sortable' => TRUE,
                                                              ),

                                             'argument' => array(
                                                                 'handler' => 'views_handler_argument',
                                                                 ),

                                             'filter' => array(
                                                               'handler' => 'views_handler_filter_string',
                                                               'allow empty' => TRUE,
                                                               ),

                                             'sort' => array(
                                                             'handler' => 'views_handler_sort',
                                                             ),
                                             );
                                             
  //url HOMEPAGE
  $data['matchdart_venues']['homepage'] = array(
                                             'title' => t('Homepage'),
                                             'help' => t('URL to Venue Homepage.'),
                                             'field' => array(
                                                              'handler' => 'views_handler_field_url',
                                                              'click sortable' => TRUE,
                                                              ),

                                             'argument' => array(
                                                                 'handler' => 'views_handler_argument',
                                                                 ),

                                             'filter' => array(
                                                               'handler' => 'views_handler_filter_string',
                                                               'allow empty' => TRUE,
                                                               ),

                                             'sort' => array(
                                                             'handler' => 'views_handler_sort',
                                                             ),
                                             );
                                             
  //EMAIL
  $data['matchdart_venues']['email'] = array(
                                             'title' => t('Email'),
                                             'help' => t('Help Email.'),
                                             'field' => array(
                                                              'handler' => 'views_handler_field',
                                                              'click sortable' => TRUE,
                                                              ),

                                             'argument' => array(
                                                                 'handler' => 'views_handler_argument',
                                                                 ),

                                             'filter' => array(
                                                               'handler' => 'views_handler_filter_string',
                                                               'allow empty' => TRUE,
                                                               ),

                                             'sort' => array(
                                                             'handler' => 'views_handler_sort',
                                                             ),
                                             );
                                             
  //url LOGO
  $data['matchdart_venues']['logo'] = array(
                                             'title' => t('Logo'),
                                             'help' => t('URL to Venue Logo.'),
                                             'field' => array(
                                                              'handler' => 'views_handler_field_url',
                                                              'click sortable' => TRUE,
                                                              ),

                                             'argument' => array(
                                                                 'handler' => 'views_handler_argument',
                                                                 ),

                                             'filter' => array(
                                                               'handler' => 'views_handler_filter_string',
                                                               'allow empty' => TRUE,
                                                               ),

                                             'sort' => array(
                                                             'handler' => 'views_handler_sort',
                                                             ),
                                             );
                                           
  //SUBSTITUTE (from matchdart_venues.nid)
  $data['matchdart_venues']['substitute'] = array(
                                                'title' => t('Substitute'),
                                                'help' => t('Relates a Substitute Venue to the Venue.'),
                                                'field' => array(
                                                                 'handler' => 'views_handler_field_numeric',
                                                                 'click sortable' => TRUE,
                                                                 ),
                                                'sort' => array(
                                                                'handler' => 'views_handler_sort',
                                                                ),
                                                'relationship' => array(
                                                                        'base' => 'node',
                                                                        'field' => 'nid',
                                                                        'handler' => 'views_handler_relationship',
                                                                        'label' => t('MatchDart! Venue: Substitute'),
                                                                        ),
                                                );

                                             
                                                 
return $data;  
}


